<template>
  <div>
    <div class="list">
      <div class="col" v-for="(item, index) in list" :key="item.id">
        <div class="item">
          <div class="time">{{ item.message }}</div>
          <div class="num">{{ item.time }}</div>
        </div>
      </div>
    </div>
    <pagination
      :total="total"
      :currentPage="page"
      :pageSize="rows"
      @handleCurrentChange="handleCurrentChange"
    />
  </div>
</template>

<script>
export default {
  name: "NavBar",
  data() {
    return { page: 1, total: 0, list: [], rows: 10 };
  },
  components: {
    pagination: () => import("@/components/pagination.vue"),
  },
  mounted() {
    this.getList();
  },
  methods: {
    getList() {
      this.$post("/user/message_list", {
        page: this.page,
        rows: this.rows,
      }).then((res) => {
        this.list = res.data.data;
        this.total = res.data.total;
      });
    },
    handleCurrentChange(e) {
      this.page = e;
      this.getList();
    },
  },
};
</script>

<style scoped lang="scss">
.list {
  .col {
    padding: 5px 0;
    .item {
      background: #f4f4f4;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 5px 10px;
    }
  }
}
@media screen and (max-width: 768px) {
}
</style>
